package com.iplant.base.utils.general;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.iplant.base.utils.BaseConfigConstans;

import net.coobird.thumbnailator.Thumbnails;

public class ThumbnailsUtils {

	private static Logger logger = LoggerFactory.getLogger(ThumbnailsUtils.class);

	public static void Compress(String wSource, String wOutSource) {

		try {
			Thumbnails.of(wSource).scale(BaseConfigConstans.UploadImageScale)
					.outputQuality(BaseConfigConstans.UploadImageQuality).toFile(wOutSource);

		} catch (Exception e) {
			logger.error(e.toString());
		}

	}

	public static void Compress(String wSource) {

		try {
			Thumbnails.of(wSource).scale(BaseConfigConstans.UploadImageScale)
					.outputQuality(BaseConfigConstans.UploadImageQuality).toFile(wSource);

		} catch (Exception e) {
			logger.error(e.toString());
		}

	}

	public static void Compress(String wSource, float wUploadImageScale, float wUploadImageQuality) {

		try {
			Thumbnails.of(wSource).scale(wUploadImageScale).outputQuality(wUploadImageQuality).toFile(wSource);

		} catch (Exception e) {
			logger.error(e.toString());
		}

	}

	public static void Compress(String wSource, String wOutSource, float wUploadImageScale, float wUploadImageQuality) {

		try {
			Thumbnails.of(wSource).scale(wUploadImageScale).outputQuality(wUploadImageQuality).toFile(wOutSource);

		} catch (Exception e) {
			logger.error(e.toString());
		}

	}
}
